/*
 * @FilePath: /liveness/vite.base.config.ts
 * 介绍:无论哪个环境都会执行的配置项
 */
import react from "@vitejs/plugin-react";

import { defineConfig, ConfigEnv } from "vite";
import path from "path";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import postcssPresetEnv from "postcss-preset-env";

export default (config: ConfigEnv) =>
  defineConfig({
    base: "./",
    resolve: {
      alias: {
        "@@": path.join(__dirname, "src"),
        "@@defaHttp": path.join(__dirname, "src/utils/defaHttp/index"),
      },
    },
    css: {
      preprocessorOptions: {
        postcss: {
          //查postcss文档
          plugins: [postcssPresetEnv()], //使用postcss的预设环境
        },
      },
    },
    plugins: [
      react(),
      AutoImport({
        imports: ["react"],
        dts: "./types/dts/auto-import/imports.d.ts",
      }),
      Components({
        dirs: ["src/components"],
        deep: true,
        extensions: ["tsx"],
        dts: "./types/dts/auto-import/components.d.ts",
      }),
    ],
  });
